<?php
namespace Consumer;
use Workerman\MYSQL\Connection as MysqlOpt;
use Workerman\REDIS\Redis as RedisOpt;

class Tool {

	//获取redis
    public static function getRedisModule() {
        $module = RedisOpt::getIns();
        $module->connect(['host' => '127.0.0.1', 'port' => 6379]);
		return $module;
    }

	//获取数据库操作
    public static function getMysqlModule() {
        return new MysqlOpt('121.40.31.70', '3306', 'dev_ywy', 'ywy2017', 'dev_ywy');
    }
	
	//删除用户和门的关联信息
	public  static  function deleteUserDoorInfo($userid){
		$redis = self::getRedisModule();
		$key = USER_DOOR_STATUS.$userid;
		$door_id = $redis->get($key);
		$redis->multi();
		$redis->remove(DOOR_STATUS.$door_id);
		$redis->remove($key);
		$redis->remove(USER_DOOR_RE.$door_id);
		$redis->exec();
		return true;
	}
}

?>